package com.sgcc.system.api.factory;

import com.sgcc.common.core.domain.R;
import com.sgcc.system.api.RemoteAreaService;
import com.sgcc.system.api.RemoteDistrictService;
import com.sgcc.system.api.domain.SysArea;
import com.sgcc.system.api.domain.SysDistrict;
import com.sgcc.system.api.model.LoginUser;
import feign.hystrix.FallbackFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

/**
 * 用户部门服务降级处理
 * 
 * @author sgcc
 */
@Component
public class RemoteAreaFallbackFactory implements FallbackFactory<RemoteAreaService>
{
    private static final Logger log = LoggerFactory.getLogger(RemoteAreaFallbackFactory.class);

    @Override
    public RemoteAreaService create(Throwable throwable)
    {
        log.error("用户服务调用失败:{}", throwable.getMessage());
        return new RemoteAreaService()
        {


            @Override
            public List<SysArea> getArealistBycode(List<String> orgList) {
                // TODO Auto-generated method stub
                List<SysArea> SysDistrict= new ArrayList<>();
                log.info("获取单位编码失败请稍后在试");
                return SysDistrict;
            }

            @Override
            public SysArea getAreaBycode(String code) {
                log.info("获取区域失败请稍后在试");
                return null;
            }

            @Override
            public R<SysArea> getAreaByDeptId(String deptId) {
                return R.fail();
            }
        };
    }
}
